package com.itlong.cloud.POJO.VO.sdk;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <desc>
 *      人脸识别API访客列表VO
 * </desc>
 *
 * @createDate 2019/11/11
 */

@Data
@NoArgsConstructor
public class SDKFaceVisitorInfoVO {

    private String intervieweeName;         //受访人姓名
    private String visitorName;             //访客姓名
    private String visitorPhone;            //访客手机
    private String address;                 //使用地址
    private Integer isExpired;              //是否过期 1未过期 2已过期
    private String createTime;              //创建时间

    private String startTime;               //有效起始时间
    private String endTime;                 //有效结束时间


    //人脸头像地址
    private String facePicUrl;

    @JsonIgnore
    private String roomId;

    public Integer getIsExpired() {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        if (StringUtils.isEmpty(String.valueOf(startTime)) && StringUtils.isEmpty(String.valueOf(endTime))) {
            return null;
        }else{
            try {
                Date startDate = df.parse(startTime);
                Date endDate = df.parse(endTime);
                Date nowDate = df.parse(df.format(new Date()));
                if((nowDate.getTime()>=startDate.getTime()) && (nowDate.getTime()<=endDate.getTime()) ){
                    return 1;
                }else if(nowDate.getTime()<startDate.getTime()){
                    return 1;
                } else{
                    return 2;
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }

        }
        return null;
    }

}